<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>等级符号专题图</title>
    <script type="text/javascript" src="../../dist/include-openlayers.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
<div id="map" style="width: 100%;height:100%"></div>
<script type="text/javascript">
    var map, themeLayer, options,
        url = (window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090")+"/iserver/services/map-china400/rest/maps/China";
    var mapService = new ol.supermap.MapService(url);
    mapService.getMapInfo(function (serviceResult) {
        var mapJSONObj = serviceResult.result;
        map = new ol.Map({
            target: 'map',
            controls: ol.control.defaults({attributionOptions: {collapsed: false}})
                .extend([new ol.supermap.control.Logo()]),
            view: new ol.View({
                center: [12406035, 4304933],
                zoom: 4,
                projection: "EPSG:3857"
            })
        });
        options = ol.source.TileSuperMapRest.optionsFromMapJSON(url, mapJSONObj);
        var layer = new ol.layer.Tile({
            source: new ol.source.TileSuperMapRest(options)
        });
        map.addLayer(layer);
        createTheme();
    });

    function createTheme() {
        var themeGraduatedSymbol = new SuperMap.ThemeGraduatedSymbol({
            expression: "SMAREA",
            baseValue: 3000000000000,
            graduatedMode: SuperMap.GraduatedMode.CONSTANT,
            flow: new SuperMap.ThemeFlow({
                flowEnabled: true
            }),
            style: new SuperMap.ThemeGraduatedSymbolStyle({
                positiveStyle: new SuperMap.ServerStyle({
                    markerSize: 50,
                    markerSymbolID: 0,
                    lineColor: new SuperMap.ServerColor(255, 165, 0),
                    fillBackColor: new SuperMap.ServerColor(255, 0, 0)
                })
            })
        });
        var themeParameters = new SuperMap.ThemeParameters({
            themes: [themeGraduatedSymbol],
            datasetNames: ["China_Province_pg"],
            dataSourceNames: ["China"]
        });
        new ol.supermap.ThemeService(url).getThemeInfo(themeParameters, function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer = new ol.layer.Tile({
                    source: new ol.source.TileSuperMapRest({
                        url: url,
                        noWrap: true,
                        cacheEnabled: false,
                        transparent: true,
                        layersID: result.newResourceID,
                        transparent: true
                    })
                });
                map.addLayer(themeLayer);
            }
        });
    }
</script>
</body>
</html>